function SecondAssistant() {
	this.ajax = {
		url: 'http://psi.example.com:3000/users',
		success: function() { info('ajax success'); },
		error: function() { info('ajax error'); },
		complete: function() { this.activeBtn.mojo.deactivate(); }.bind(this)
	};
	jQuery.ajaxSetup(this.ajax);
}

function info(msg) {
	var doc = 	Mojo.Controller.getAppController().getActiveStageController().document;
	jQuery('#info', doc).html(msg);
}


// two things odd with webos jquery ajax post
//  - undefined in payload if data is not set explicilty
//  - post is turned into get if data is present in any form (null, '')
SecondAssistant.prototype.onRegister = function() {
	info('registering user');
	jQuery.ajax({
		url: this.ajax.url + ".json",
		type: 'post',
		data: 'mock=smth'
	});
};
SecondAssistant.prototype.onDestroy = function() {
	var user = cookie.get().user;
	cookie.destroy();
	jQuery.ajax({
		url: this.ajax.url,
		type: 'delete',
		data: 'mock=smth'
	});
};

SecondAssistant.prototype.setup = function() {
	var c = this.controller, e = Mojo.Event;
	c.setupWidget('register', {}, { label: 'Register' });
	c.listen('register', e.tap, this.onRegister.bind(this));
	c.setupWidget('destroy', {}, { label: 'Destroy' });
	c.listen('destroy', e.tap, this.onDestroy.bind(this));
	info('instant reload ok!');
};


SecondAssistant.prototype.activate = function(event) {};
SecondAssistant.prototype.deactivate = function(event) {};
SecondAssistant.prototype.cleanup = function(event) {};
